<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>后台登录</title>
    <link rel="shortcut icon" href="../favicon.ico"> <link href="../css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="../css/font-awesome.min.css?v=4.4.0" rel="stylesheet">

    <link href="../css/animate.min.css" rel="stylesheet">
    <link href="../css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <link href="../css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
</head>

<body class="gray-bg">

<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <div>
            <h1 class="logo-name">H+</h1>
        </div>
        <h3>欢迎使用后台管理系统</h3>
        <form id="loginForm">
            <div class="form-group">
                <input type="type"id="account" name="account" class="form-control" required="required" placeholder="用户名">
            </div>
            <div class="form-group">
                <input type="password" id="password" name="password" class="form-control" required="required" placeholder="密码">
            </div>
            <button type="button" id="btn" class="btn btn-primary block full-width m-b">登 录</button>
        </form>

            <p class="text-muted text-center"> <a href="login.html#"><small>忘记密码了？</small></a> | <a href="register.html">注册一个新账号</a>
            </p>
    </div>
</div>
<script src="../js/jquery.min.js?v=2.1.4"></script>
<script src="../js/bootstrap.min.js?v=3.3.5"></script>
<script src="../js/plugins/jquery.cookie.js"></script>
<script src="../js/plugins/toastr/toastr.min.js"></script>
<script src="../js/plugins/validate/jquery.validate.min.js"></script>
<script src="../js/plugins/validate/messages_zh.min.js"></script>
<script src="../js/common.js"></script>
<script>
    $(function(){
        $("#btn").click(function(){
            if(!$("#loginForm").validate().form()) {
                return;
            }
            var account=$("#account").val();
            var password=$("#password").val();
            ajaxPost({
                url:"sysUser/login",
                data:{"account":account,"password":password},
                success:function(data){
                    $.cookie("token",data.data.token,{path:"/" ,expires:365});
                    $.cookie("name",data.data.name,{path:"/",expires:365});
                    $.cookie("type",data.data.type,{path:"/",expires:365});
                    var url=getQueryString("redirect_url");
                    if(url){
                        window.location.href=decodeURIComponent(url);
                        return;
                    }
                    window.location.href="../index.html";
                }
            })
        });

        window.onkeydown=function(e){
            if(e.key=="Enter"){
                $("#btn").trigger("click");
            }
        }
    })
</script>
</body>

</html>